﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace TG_2_LP
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
             Thread.CurrentThread.CurrentCulture = new CultureInfo("en");

             
            chart1.Series["Values"].Color = Color.Blue;
            
            chart1.Series["Values"].SmartLabelStyle.Enabled = false;
            chart1.Series["Values"].LabelAngle = -90;    // This will rotate Data Label
            chart1.Series["Values"].IsValueShownAsLabel = true;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
            chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;               
            chart1.Series["Values"].IsXValueIndexed = true;
            chart1.ChartAreas[0].AxisX.Interval = 1;
            chart1.ChartAreas[0].AxisX.LabelStyle.Angle = -90;
           
            

           

            ReadExel.readExel();            
            DB.Program();       
            Console.ReadLine();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.chart1.Series["Values"].Points.Clear();
            
           string anoI = textBox1.Text;
           string anoF = textBox2.Text;



           if (comboBox1.SelectedIndex == 0)
            {
                DB.getGraph("IPC", anoI, anoF);
                for (int i = 0; i < DB.anos.Count; i++)   
                     chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
            }
           if (comboBox1.SelectedIndex == 1)
           {
               DB.getGraph("VarAn", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 2)
           {
               DB.getGraph("rMinM", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 3)
           {
               DB.getGraph("rMaxM", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 4)
           {
               DB.getGraph("PIB", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 5)
           {
               DB.getGraph("RendNac", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 6)
           {
               DB.getGraph("RendDisp", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
           if (comboBox1.SelectedIndex == 7)
           {
               DB.getGraph("Renume", anoI, anoF);
               for (int i = 0; i < DB.anos.Count; i++)
                   chart1.Series["Values"].Points.AddXY(DB.anos[i], DB.values[i]);
           }
            
        }

        


        private void chart1_Click(object sender, EventArgs e)
        {

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
